package com.etlmaster.executor.steps.table;

import java.util.List;
import java.util.Map;

import com.etlmaster.executor.StepMeta;
import com.etlmaster.executor.utils.DataCollectionUtils;
import com.etlmaster.executor.utils.JsonHelper;
import com.etlmaster.jdbc.JdbcTemplate;

/**
 * 
 * @author MeiKefu
 *
 */
public class CreateTableStepMeta extends StepMeta {

	@Override
	protected void loadParamsFromConfigTable() {

	}

	protected String xmlId;

	protected String tableName;

	protected String metaTableName;

	protected String dsName;

	protected String override;

	protected String db2DistributionKey;

	private String extractParam;

	public void setDb2DistributionKey(String db2DistributionKey) {
		this.db2DistributionKey = db2DistributionKey;
	}

	protected String tbsSpace;

	protected String indexSpace; // 增加索引空间

	protected String hiveDelimited = "\\t";

	protected String hivePartitionKey;

	protected String hiveStoreType = "textfile";

	protected String hiveLocation;

	protected List<Map<String, Object>> columns;

	protected String schemaName;

	protected String userName;

	protected String password;

	private String creater;

	private String eff_date;

	public CreateTableStepMeta(String id, String name,String step_code, String session_id, String paramStr) {
		super(id, name,step_code, session_id, paramStr);
	}
	public String getXmlId() {
		if(this.xmlId==null)
			return DataCollectionUtils.getXmlId(getMetaTableName(), getDsName(), new JdbcTemplate());
		else
			return variableSubstitution(xmlId);
	}

	public String getTableName() {
		return variableSubstitution(tableName);
	}

	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

	public String getMetaTableName() {
		return variableSubstitution(metaTableName);
	}

	public String getDsName() {
		return variableSubstitution(dsName);
	}

	public String getOverride() {
		return override;
	}

	public String getDb2DistributionKey() {
		return db2DistributionKey;
	}

	public String getTbsSpace() {
		return tbsSpace;
	}

	public String getHiveDelimited() {
		return hiveDelimited;
	}

	public String getHivePartitionKey() {
		return hivePartitionKey;
	}

	void setHivePartitionKey(String hivePartitionKey) {
		this.hivePartitionKey = hivePartitionKey;
	}

	public String getHiveStoreType() {
		return hiveStoreType;
	}

	public String getHiveLocation() {
		return hiveLocation;
	}

	public List<Map<String, Object>> getColumns() {
		return columns;
	}

	public void setColumns(List<Map<String, Object>> columns) {
		this.columns = columns;
	}

	public String getSchemaName() {
		return schemaName;
	}

	public String getUserName() {
		return userName;
	}

	public String getPassword() {
		return password;
	}

	public void setXmlId(String xmlId) {
		this.xmlId = xmlId;
	}

	public void setMetaTableName(String metaTableName) {
		this.metaTableName = metaTableName;
	}

	public void setDsName(String dsName) {
		this.dsName = dsName;
	}

	public void setOverride(String override) {
		this.override = override;
	}

	public void setTbsSpace(String tbsSpace) {
		this.tbsSpace = tbsSpace;
	}

	public void setHiveDelimited(String hiveDelimited) {
		this.hiveDelimited = hiveDelimited;
	}

	public void setHiveStoreType(String hiveStoreType) {
		this.hiveStoreType = hiveStoreType;
	}

	public void setHiveLocation(String hiveLocation) {
		this.hiveLocation = hiveLocation;
	}

	public void setSchemaName(String schemaName) {
		this.schemaName = schemaName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getIndexSpace() {
		return indexSpace;
	}

	public void setIndexSpace(String indexSpace) {
		this.indexSpace = indexSpace;
	}

	public String getCreater() {
		if (creater != null)
			return creater;
		else {
			return "";
		}
	}

	public void setCreater(String creater) {
		this.creater = creater;
	}

	public String getEff_date() {
		if (eff_date != null)
			return eff_date;
		else {
			return "";
		}
	}

	public Map<String, String> getExtraParam() {
		if (this.extractParam != null && this.extractParam.length() > 0) {
			
			Map<String,String> map=(Map<String, String>) JsonHelper.getInstance().read(variableSubstitution(this.extractParam));
			return map;
		} else {
			return null;
		}
	}

	public void setEff_date(String eff_date) {
		this.eff_date = eff_date;
	}

	public String getExtractParam() {
		return extractParam;
	}

	public void setExtractParam(String extractParam) {
		this.extractParam = extractParam;
	}
	

}
